/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nsip.components.ds;

import nsip.components.ds.bi.Metric;
import java.util.EnumMap;
import java.util.Map;

/**
 *
 * @author nico.rehwaldt
 */
public class StatisticDataBase<T extends Enum> {

    private StatisticMap countersMap;
    private Map<T, Metric> metricsMap;
    
    public StatisticDataBase(Class<T> cls) {
        countersMap = new StatisticMap();
        metricsMap = new EnumMap(cls);
    }
    
    public StatisticMap counters() {
        return countersMap;
    }
    
    public Metric getMetric(StatisticType type) {
        Metric metric = metricsMap.get(type);
        if (metric == null) {
            throw new IllegalArgumentException(
                "Metric does not exist for type " + type);
        }
        return metric;
    }
    
    public final void addMetric(T type, Metric metric) {
        metricsMap.put(type, metric);
    }

    @Override
    public String toString() {
        return "{ counters: " + countersMap + ", metrics: " + metricsMap + "}";
    }
}
